package com.jason.fingerprint.utils;

import com.jason.fingerprint.beans.LeaveOutBean;
import com.jason.fingerprint.beans.LeaveOutCacheBean;

import org.kymjs.aframe.database.KJDB;

import java.util.ArrayList;
import java.util.List;

public class StringUtils {

    public static final LeaveOutCacheBean getLeaveOutCacheBean(LeaveOutBean leaveOutBean){
        LeaveOutCacheBean leaveOutCacheBean = new LeaveOutCacheBean();
        leaveOutCacheBean.setId(leaveOutBean.getId());
        leaveOutCacheBean.setLeaveoutId(leaveOutBean.getLeaveoutId());
        leaveOutCacheBean.setTime(leaveOutBean.getTime());
        leaveOutCacheBean.setSignFlag(leaveOutBean.getSignFlag());
        leaveOutCacheBean.setRymcid(leaveOutBean.getRymcid());
        leaveOutCacheBean.setName(leaveOutBean.getName());
        leaveOutCacheBean.setPhotoUrl(leaveOutBean.getPhotoUrl());
        leaveOutCacheBean.setSignType(leaveOutBean.getSignType());
        leaveOutCacheBean.setIsCancel(leaveOutBean.getIsCancel());
        leaveOutCacheBean.setLeaveId(leaveOutBean.getLeaveId());
        leaveOutCacheBean.setIsCancelLeave(leaveOutBean.getIsCancelLeave());
        leaveOutCacheBean.setOrganid(leaveOutBean.getOrganid());
        leaveOutCacheBean.setOrgan(leaveOutBean.getOrgan());
        leaveOutCacheBean.setState(leaveOutBean.getState());
        leaveOutCacheBean.setCreateTime(leaveOutBean.getCreateTime());
        leaveOutCacheBean.setRegistrationType(leaveOutBean.getRegistrationType());
        leaveOutCacheBean.setBegintime(leaveOutBean.getBegintime());
        leaveOutCacheBean.setEndtime(leaveOutBean.getEndtime());
        leaveOutCacheBean.setLeavedays(leaveOutBean.getLeavedays());
        leaveOutCacheBean.setAddress(leaveOutBean.getAddress());
        leaveOutCacheBean.setLeavereason(leaveOutBean.getLeavereason());
        leaveOutCacheBean.setSq_sj(leaveOutBean.getSq_sj());
        leaveOutCacheBean.setSq_organ(leaveOutBean.getSq_organ());
        leaveOutCacheBean.setSq_yj(leaveOutBean.getSq_yj());
        leaveOutCacheBean.setSp_sj(leaveOutBean.getSp_sj());
        leaveOutCacheBean.setSp_organ(leaveOutBean.getSp_organ());
        leaveOutCacheBean.setSp_yj(leaveOutBean.getSp_yj());
        return leaveOutCacheBean;
    }

    public static final LeaveOutBean getLeaveOutBean(LeaveOutCacheBean leaveOutCacheBean){
        LeaveOutBean leaveOutBean = new LeaveOutBean();
        leaveOutBean.setId(leaveOutCacheBean.getId());
        leaveOutBean.setLeaveoutId(leaveOutCacheBean.getLeaveoutId());
        leaveOutBean.setTime(leaveOutCacheBean.getTime());
        leaveOutBean.setSignFlag(leaveOutCacheBean.getSignFlag());
        leaveOutBean.setRymcid(leaveOutCacheBean.getRymcid());
        leaveOutBean.setName(leaveOutCacheBean.getName());
        leaveOutBean.setPhotoUrl(leaveOutCacheBean.getPhotoUrl());
        leaveOutBean.setSignType(leaveOutCacheBean.getSignType());
        leaveOutBean.setIsCancel(leaveOutCacheBean.getIsCancel());
        leaveOutBean.setLeaveId(leaveOutCacheBean.getLeaveId());
        leaveOutBean.setIsCancelLeave(leaveOutCacheBean.getIsCancelLeave());
        leaveOutBean.setOrganid(leaveOutCacheBean.getOrganid());
        leaveOutBean.setOrgan(leaveOutCacheBean.getOrgan());
        leaveOutBean.setState(leaveOutCacheBean.getState());
        leaveOutBean.setCreateTime(leaveOutCacheBean.getCreateTime());
        leaveOutBean.setRegistrationType(leaveOutCacheBean.getRegistrationType());
        leaveOutBean.setBegintime(leaveOutCacheBean.getBegintime());
        leaveOutBean.setEndtime(leaveOutCacheBean.getEndtime());
        leaveOutBean.setLeavedays(leaveOutCacheBean.getLeavedays());
        leaveOutBean.setAddress(leaveOutCacheBean.getAddress());
        leaveOutBean.setLeavereason(leaveOutCacheBean.getLeavereason());
        leaveOutBean.setSq_sj(leaveOutCacheBean.getSq_sj());
        leaveOutBean.setSq_organ(leaveOutCacheBean.getSq_organ());
        leaveOutBean.setSq_yj(leaveOutCacheBean.getSq_yj());
        leaveOutBean.setSp_sj(leaveOutCacheBean.getSp_sj());
        leaveOutBean.setSp_organ(leaveOutCacheBean.getSp_organ());
        leaveOutBean.setSp_yj(leaveOutCacheBean.getSp_yj());
        return leaveOutBean;
    }

    public static final List<LeaveOutBean> getLeaveOutBeans(List<LeaveOutCacheBean> cacheBeans){
        List<LeaveOutBean> outBeans = new ArrayList<LeaveOutBean>();
        if (cacheBeans != null && !cacheBeans.isEmpty()){
            for (LeaveOutCacheBean bean : cacheBeans) {
                outBeans.add(getLeaveOutBean(bean));
            }
        }
        return outBeans;
    }

    public static final List<LeaveOutCacheBean> getLeaveOutCacheBeans(List<LeaveOutBean> outBeans){
        List<LeaveOutCacheBean> cacheBeans = new ArrayList<LeaveOutCacheBean>();
        if (outBeans != null && !outBeans.isEmpty()){
            for (LeaveOutBean bean : outBeans) {
                cacheBeans.add(getLeaveOutCacheBean(bean));
            }
        }
        return cacheBeans;
    }

    public static void saveLeaveOutCacheBeansToSql(List<LeaveOutBean> outBeans, KJDB kjdb){
        if (kjdb != null && outBeans!= null && !outBeans.isEmpty()){
            if (outBeans != null && !outBeans.isEmpty()){
                for (LeaveOutBean bean : outBeans) {
                    kjdb.save(getLeaveOutCacheBean(bean));
                }
            }
        }
    }
}
